﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace Runda.EShop.Common.Utility
{
    public static class LogHelper
    {
        public static void Write(string Message)
        {
            Write(Message, string.Empty, LogCategorySource.FileLog, 0, 0, System.Diagnostics.TraceEventType.Information);
        }

        public static void Write(string Message,LogCategorySource Source)
        {
            Write(Message, string.Empty, Source, 0, 0, System.Diagnostics.TraceEventType.Information);
        } 
        
        public static void Write(string Message,string Title,LogCategorySource Source)
        {
            Write(Message, Title, Source, 0, 0, System.Diagnostics.TraceEventType.Information);
        }

        public static void Write(string Message, LogCategorySource Source,System.Diagnostics.TraceEventType Type)
        {
            Write(Message, string.Empty, Source, 0, 0, Type);
        }

        public static void Write(string Message,string Title,LogCategorySource Source,int Priority,int EventID,System.Diagnostics.TraceEventType TraceEventType)
        {
            string Category = "FileLog";
            if (Source == LogCategorySource.WMSServiceLog)
                Category = "WMSServiceLog";
            else if (Source == LogCategorySource.WMSServiceDataLog)
                Category = "WMSServiceDataLog";

            Logger.Writer.Write(Message, Category, Priority, EventID, TraceEventType, Title);
        }
    }

    /// <summary>
    /// 日志类型
    /// </summary>
    public enum LogCategorySource
    {
        /// <summary>
        /// 文件
        /// </summary>
        FileLog,
        /// <summary>
        /// 异常
        /// </summary>
        WMSServiceLog,
        /// <summary>
        /// 数据
        /// </summary>
        WMSServiceDataLog,
    }
}
